USE Liberty
GO

-- ------------------------------------------------------------------------------------------------
-- Applicants Table Create Script
-- ------------------------------------------------------------------------------------------------
SET NOCOUNT OFF
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
SET ARITHABORT ON
SET CONCAT_NULL_YIELDS_NULL ON
SET QUOTED_IDENTIFIER ON
SET NUMERIC_ROUNDABORT OFF
GO

PRINT 'Creating Table dbo.Applicants...'
GO

IF OBJECT_ID('dbo.Applicants', 'U') IS NULL
BEGIN
	CREATE TABLE dbo.Applicants
	(OID				bigint			NOT NULL
	,Version			rowversion
	,KinshipID			bigint			NOT NULL
	,AddressID			bigint			NOT NULL
	,UpdatedDate		datetime		NOT NULL
		CONSTRAINT DFLT_Applicants_UpdatedDate DEFAULT GETDATE()
	,CreatedDate		datetime		NOT NULL
		CONSTRAINT DFLT_Applicants_CreatedDate DEFAULT GETDATE()

	,CONSTRAINT PK_Applicants PRIMARY KEY CLUSTERED( OID ) --ON PRIMARY

	,CONSTRAINT FK_Applicants_People FOREIGN KEY (OID)
		REFERENCES People(OID)

	,CONSTRAINT FK_Applicants_TypesOfKinship FOREIGN KEY (KinshipID)
		REFERENCES TypesOfKinship(OID)

	,CONSTRAINT FK_Applicants_Addresses FOREIGN KEY (AddressID)
		REFERENCES Addresses(OID)

	)

	PRINT 'Table dbo.Applicants has been created successfully.'

END
ELSE 
BEGIN
    PRINT 'Table dbo.Applicants already exists.'
END

GO
